package com.winner.data.controller;

import com.alibaba.fastjson.JSON;
import com.winner.data.dao.UserRepository;
import com.winner.data.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.List;

/**
 * 控制层 打印userService.getClass, 或debug查看变量userService, springboot2.0以后默认使用Cglib实现动态代理
 *
 * @author wangxinle5
 * @since 2023-01-03
 */
@RestController
@RequestMapping("/")
public class UserController {

    @Resource
    UserRepository userRepository;

    /**
     * localhost:8080/getData
     *
     * @return 结果
     */
    @ResponseBody
    @GetMapping("/getData")
    public List<User>  getData() {
        List<User> list = userRepository.findUserByUsername("sino");
        return list;
    }

}
